﻿using MongoDB.Driver;
using System.Linq.Expressions;
using System.Text.RegularExpressions;

namespace MyMongoDB
{
    public interface IMongoDBManage
    {
        /// <summary>
        /// 创建集合
        /// </summary>
        /// <param name="collectionName"></param>
        public void CreateCollection<T>(string collectionName, T obj);
        /// <summary>
        /// 异步插入一条数据，手动输入collection name
        /// </summary>
        public Task InsertAsync<T>(string collectionName, T obj);

        /// <summary>
        /// 异步插入一条数据，采用类型T的完全限定名作为collection name
        /// </summary>
        public Task InsertAsync<T>(T obj);

        /// <summary>
        /// 异步插入多条数据，手动输入collection name
        /// </summary>
        public Task BatchInsertAsync<T>(string collectionName, IEnumerable<T> objs);

        /// <summary>
        /// 异步插入多条数据，采用类型T的完全限定名作为collection name
        /// </summary>
        public Task BatchInsertAsync<T>(IEnumerable<T> objs);

        /// <summary>
        /// 插入一条数据
        /// </summary>
        public void Insert<T>(T obj);
        /// <summary>
        /// 插入一条数据
        /// </summary>
        public void Insert<T>(T obj, string name);

        /// <summary>
        /// 插入多条数据
        /// </summary>
        public void Insert<T>(IEnumerable<T> objs);

        /// <summary>
        /// MongoDB C# Driver的Find方法，返回IFindFluent。手动输入collection name
        /// </summary>
        public IFindFluent<T, T> Find<T>(string collectionName, FilterDefinition<T> filter, FindOptions options = null);

        /// <summary>
        /// MongoDB C# Driver的Find方法，返回IFindFluent。采用类型T的完全限定名作为collection name
        /// </summary>
        public IFindFluent<T, T> Find<T>(FilterDefinition<T> filter, FindOptions options = null);

        /// <summary>
        /// 取符合条件的数据 sort中多个排序条件逗号分隔，默认asc
        /// </summary>
        public List<T> Get<T>(Expression<Func<T, bool>> condition, int skip, int limit, string sort);

        public List<T> Get<T>(Expression<Func<T, bool>> condition);

        /// <summary>
        /// 取符合条件的数据 sort中多个排序条件逗号分隔，默认asc
        /// </summary>
        public List<T> Get<T>(List<Expression<Func<T, bool>>> conditions, int skip, int limit, string sort);

        public List<T> Get<T>(List<Expression<Func<T, bool>>> conditions);
        /// <summary>
        /// 获取集合
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="collectionName"></param>
        /// <returns></returns>
        public object GetCollection<T>(string collectionName);
        /// <summary>
        /// 获取集合文档
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="collectionName"></param>
        /// <returns></returns>
        public List<T> GetDocumentList<T>(string collectionName);
    }
}